package tako.wisers.com.android.apis.handler;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import tako.wisers.com.android.apis.event.CallPhoneEvent;
import tako.wisers.com.android.apis.event.Event;

public class CallPhoneHandler implements Handler {
	private Activity mActivty;
	
	public CallPhoneHandler(Activity activity){
		mActivty = activity;
	}
	@Override
	public void execute(Event event) {
		if(!(event instanceof CallPhoneEvent)){
			return;
		}
		CallPhoneEvent cEvent = (CallPhoneEvent) event;
		String phone = cEvent.getNumber();
		if (phone != null)
			mActivty.startActivityForResult(new Intent(Intent.ACTION_DIAL, Uri
					.parse("tel:" + phone.trim())), 1);
	}

}
